package com.naiterui.ehp.bp.enums;

/**
 * 住户类型枚举 全局  1住户  2电梯
 *
 * @author 胡超雄
 * @date 2021/4/2 10:20
 * @desc
 */
public enum RoomTypeEnum {

    HOUSE(1, "住户"),
    ELEVATOR(2, "电梯"),
    ;
    private Integer code;
    private String name;

    RoomTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static RoomTypeEnum getByCode(Integer code) {
        for (RoomTypeEnum tmpEnum : values()) {
            if (tmpEnum.getCode().equals(code)) {
                return tmpEnum;
            }
        }
        return null;
    }

    public static Integer getByName(String name) {
        if (name.equals(RoomTypeEnum.HOUSE.getName())) {
            return RoomTypeEnum.HOUSE.getCode();
        } else if (name.equals(RoomTypeEnum.ELEVATOR.getName())) {
            return RoomTypeEnum.ELEVATOR.getCode();
        }
        return null;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
